package ooo.reindeer.data.option;

public enum Type {

    Int8(Type.INT8_LENGTH, Coder.INT8),
    Int16(Type.INT16_LENGTH, Coder.INT16),
    Int32(Type.INT32_LENGTH, Coder.INT32),
    Int64(Type.INT64_LENGTH, Coder.INT64),

    UnsignedInt8(Type.UNSIGNED_INT8_LENGTH, Coder.UNSIGNED_INT8),
    UnsignedInt16(Type.UNSIGNED_INT16_LENGTH, Coder.UNSIGNED_INT16),
    UnsignedInt32(Type.UNSIGNED_INT32_LENGTH, Coder.UNSIGNED_INT32),

    UnsignedInt64(Type.UNSIGNED_INT64_LENGTH, Coder.UNSIGNED_INT64),

    BaseBytes(Type.AUTO_LENGTH, Coder.BASE_BYTES),
    BaseString(Type.AUTO_LENGTH, Coder.BASE_STRING),

    DynamicBytes(Type.AUTO_LENGTH, Coder.DYNAMIC_BYTES),
    OCTBytes(Type.AUTO_LENGTH, Coder.OCT_BYTES),

    DynamicString(Type.AUTO_LENGTH, Coder.DYNAMIC_STRING),
    OCTString(Type.AUTO_LENGTH, Coder.OCT_STRING),
    Struct(Type.AUTO_LENGTH, Coder.STRUCT),

    Stream(Type.AUTO_LENGTH, Coder.STREAM),

    UnsignedIntVar(Type.AUTO_LENGTH, Coder.UNSIGNED_INT_VAR);

    public final static int INT8_LENGTH = 1;
    public final static int INT16_LENGTH = 2;
    public final static int INT32_LENGTH = 4;
    public final static int INT64_LENGTH = 8;
    public final static int UNSIGNED_INT8_LENGTH = 1;
    public final static int UNSIGNED_INT16_LENGTH = 2;
    public final static int UNSIGNED_INT32_LENGTH = 4;
    public final static int UNSIGNED_INT64_LENGTH = 8;
    public final static int AUTO_LENGTH = -1;
    private int typeLength;
    private Coder typeCoder;

    Type(int length, Coder coder) {
        this.typeLength = length;
        this.typeCoder = coder;
    }

    public Coder coder() {
        return typeCoder;
    }

    public int length() {
        return typeLength;
    }

//    public boolean contain(String name){
//        Type.valueOf(name);
//    }

}
